<?php
/**
 * Created by PhpStorm.
 * User: zsd
 * Date: 2018/4/28
 * Time: 下午2:21
 */
namespace common\traits;

use yii\data\DataProviderInterface;

trait DataProviderPagination
{
    /**
     * 返回格式化的数据
     *
     * @param \yii\data\DataProviderInterface $dataProvider
     *
     * @return array
     */
    public function returnPagination(DataProviderInterface $dataProvider)
    {
        return [
            'lists' => $dataProvider->getModels(),
            'pages' => $dataProvider->getPagination()->getPageCount(),
            'total' => $dataProvider->getTotalCount(),
        ];
    }
}
